#!/bin/sh /etc/rc.common
# Copyright (c) 2011-2015 OpenWrt.org

START=30

re=0

start(){
    enable=$(uci get flowoffload.config.enabled 2>/dev/null)
    if [ $enable -eq 1 ]; then
      echo "enable"
      sed -i '/FLOWOFFLOAD/d' /etc/firewall.user
      echo "iptables -I FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j FLOWOFFLOAD" >> /etc/firewall.user
        if [ $re -eq 0 ]; then
	echo $re
              /etc/init.d/firewall restart
        fi 
  fi
}

stop(){
    echo "stop"
    iptables -D FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j FLOWOFFLOAD
    enable=$(uci get flowoffload.config.enabled 2>/dev/null)	
    if [ $enable -ne 1 ]; then
      echo "disable"
      sed -i '/FLOWOFFLOAD/d' /etc/firewall.user
        if [ $re -ne 1 ]; then
	echo $re
              /etc/init.d/firewall restart
        fi 
    fi
}

restart(){
	re=1
	stop
	start
	/etc/init.d/firewall restart
}


